package com.pro.controller;

import com.pro.pojo.JsUserOrder;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserOrderToBeShippedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * ClassName:JsUserOrderToBeShippedController
 * Package:com.pro.controller
 * Description: 商品订单待发货列表
 *
 * @Date:2021/11/9 下午 4:50
 * @Author: WYH
 */
@Controller
@RequestMapping("/orderToBe")
public class JsUserOrderToBeShippedController {
    @Autowired
    private JsUserOrderToBeShippedService jsUserOrderToBeShippedService;

    /**
     * @author WYH
     * @date 2021/11/10 上午 11:02
     * @content : 查询所有商品订单待发货列表表格数据
     */
    @RequestMapping("/getAllorder")
    @ResponseBody
    public JsonData getAllorder(String orderPaymentChannel, String orderSource) {
        orderPaymentChannel = orderPaymentChannel != null  ? "%"+orderPaymentChannel+"%":"%%";
        orderSource = orderSource != null  ? "%"+orderSource+"%":"%%";
        List<JsUserOrder> allorder = jsUserOrderToBeShippedService.getAllorder(orderPaymentChannel, orderSource);
        int count = jsUserOrderToBeShippedService.count(orderPaymentChannel, orderSource);
        return allorder!= null ? JsonData.buildSuccess(allorder,count):JsonData.buildError("服务端错误");
    }

    /**
     * @author WYH
     * @date 2021/11/10 上午 11:02
     * @content : 查询商品订单待发货列表个数
     */
    public int count(String orderPaymentChannel, String orderSource) {
        return jsUserOrderToBeShippedService.count(orderPaymentChannel,orderSource);
    }
}
